package org.shj.spring.boot.lang;


import org.shj.spring.boot.lang.exception.BeanMapperException;

/**
 * Created by xuwei on 2017/2/16.
 */
public interface ConvertTo<E> {

    Class<E> getEntityClass();

    default E convertTo() throws BeanMapperException {
        return BeanMapper.deepMap(this, getEntityClass());
    }

    default E convertTo(E e) throws BeanMapperException {
        if (e == null) {
            return null;
        }
        BeanMapper.deepCopy(this, e);
        return e;
    }
}
